package xyz.app.domain.roles;

import lombok.*;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import xyz.app.Dao;
import xyz.app.MutableDomain;
import xyz.app.Wrapper;
import xyz.app.dependencies.HasDomainMembers;
import xyz.app.dependencies.MemberAccessor;
import xyz.app.DaoRegistry;

import java.util.Collection;
import java.util.Set;

@Slf4j
@Service/* @Lazy*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
public class DaoBranch implements Dao<Branch>,
        HasDomainMembers<Branch>,
        MutableDomain {

    @Getter @Accessors(fluent = true)
    private final DaoRegistry daoRegistry;

    @Override
    public @NonNull Class<Branch> domainClass() {
        return Branch.class;
    }

    @Getter @Accessors(fluent = true)
    private final Collection<MemberAccessor> memberAccessors = Set.of(
            MemberAccessor.of(Branch_.PARTY,    Wrapper::party,   Wrapper::party),
            MemberAccessor.of(Branch_.PARENT,   Wrapper::parent,  Wrapper::parent));
}